package com.gomcarter.frameworks.base.json;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gomcarter.frameworks.base.annotation.JsonWrapper;
import lombok.Data;

@Data
public class JsonError extends JsonObject {
    @JsonIgnore
    private JsonWrapper errorMethodAnnotation;

    public JsonError() {
    }

    public JsonError(String msg) {
        this(msg, -1);
    }

    public JsonError(ErrorCode errorCode) {
        this(errorCode.getMsg(), errorCode.getCode());
    }

    public JsonError(String msg, ErrorCode code) {
        this(msg, code.getCode());
    }

    public JsonError(String msg, Integer code) {
        this(msg, code, null);
    }

    public JsonError(String msg, Integer code, JsonWrapper errorMethodAnnotation) {
        this.code = code == null ? -1 : code;
        this.message = msg;
        this.errorMethodAnnotation = errorMethodAnnotation;
    }
}
